<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>{$data.name}</title>
    <link rel="stylesheet" href="__STATIC__assets/libs/layui/css/layui.css"/>
    <link rel="stylesheet" href="__STATIC__assets/module/admin.css?v=318"/>
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style>
        /** 数据表格中的select尺寸调整 */
        .layui-table-view .layui-table-cell .layui-select-title .layui-input {
            height: 28px;
            line-height: 28px;
        }

        .layui-table-view [lay-size="lg"] .layui-table-cell .layui-select-title .layui-input {
            height: 40px;
            line-height: 40px;
        }

        .layui-table-view [lay-size="lg"] .layui-table-cell .layui-select-title .layui-input {
            height: 40px;
            line-height: 40px;
        }

        .layui-table-view [lay-size="sm"] .layui-table-cell .layui-select-title .layui-input {
            height: 20px;
            line-height: 20px;
        }

        .layui-table-view [lay-size="sm"] .layui-table-cell .layui-btn-xs {
            height: 18px;
            line-height: 18px;
        }
          /** 统计快捷方式样式 */
        .console-link-block {
            font-size: 16px;
            padding: 20px 20px;
            border-radius: 4px;
            background-color: #40D4B0;
            color: #FFFFFF !important;
            box-shadow: 0 2px 3px rgba(0, 0, 0, .05);
            position: relative;
            overflow: hidden;
            display: block;
        }

        .console-link-block .console-link-block-num {
            font-size: 40px;
            margin-bottom: 5px;
            opacity: .9;
        }

        .console-link-block .console-link-block-text {
            opacity: .8;
        }

        .console-link-block .console-link-block-icon {
            position: absolute;
            top: 50%;
            right: 20px;
            width: 50px;
            height: 50px;
            font-size: 50px;
            line-height: 50px;
            margin-top: -25px;
            color: #FFFFFF;
            opacity: .8;
        }

        .console-link-block .console-link-block-band {
            color: #fff;
            width: 100px;
            font-size: 12px;
            padding: 2px 0 3px 0;
            background-color: #E32A16;
            line-height: inherit;
            text-align: center;
            position: absolute;
            top: 8px;
            right: -30px;
            transform-origin: center;
            transform: rotate(45deg) scale(.8);
            opacity: .95;
            z-index: 2;
        }

        /** //统计快捷方式样式 */

        /** 设置每个快捷块的颜色 */
        .layui-row > div:nth-child(2) .console-link-block {
            background-color: #55A5EA;
        }

        .layui-row > div:nth-child(3) .console-link-block {
            background-color: #9DAFFF;
        }

        .layui-row > div:nth-child(4) .console-link-block {
            background-color: #F591A2;
        }

        .layui-row > div:nth-child(5) .console-link-block {
            background-color: #FEAA4F;
        }

        .layui-row > div:last-child .console-link-block {
            background-color: #9BC539;
        }
    </style>
</head>
<body onscroll="layui.admin.hideFixedEl();">
<!-- 正文开始 -->
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md3 layui-col-sm4 layui-col-xs6">
            <div class="console-link-block">
                <div class="console-link-block-num">{$data.todayMoney_jintian} <span style="font-size: 22px;line-height: 1;">元</span></div>
                <div class="console-link-block-text">今日收入</div>
               
               
            </div>
        </div>
        <div class="layui-col-md3 layui-col-sm4 layui-col-xs6">
            <div class="console-link-block">
                <div class="console-link-block-num">{$data.todayMoney_zuotian} <span style="font-size: 22px;line-height: 1;">元</span></div>
                <div class="console-link-block-text">昨日收入</div>
               
               
            </div>
        </div>
        <div class="layui-col-md3 layui-col-sm4 layui-col-xs6">
            <div class="console-link-block">
                <div class="console-link-block-num">{$data.todayMoney_benzho} <span style="font-size: 22px;line-height: 1;">元</span></div>
                <div class="console-link-block-text">本周收入</div>
                
                
            </div>
        </div>
        <div class="layui-col-md3 layui-col-sm4 layui-col-xs6">
            <div class="console-link-block">
                <div class="console-link-block-num">{$data.todayMoney_benyue} <span style="font-size: 22px;line-height: 1;">元</span></div>
                <div class="console-link-block-text">本月收入</div>
                
                
            </div>
        </div>
       
    </div>
    <br>
    <div class="layui-card">
        <div class="layui-card-body">
            <!-- 表格工具栏 -->
            <form class="layui-form toolbar table-tool-mini">
                <div class="layui-form-item">
                       
                        <div class="layui-inline">
                        <label class="layui-form-label w-auto">订单号:</label>
                        <div class="layui-input-inline">
                            <input name="order_id" class="layui-input" type="text" placeholder="查询的订单号"/>
                            
                        </div>
                        </div>
                        <div class="layui-inline">
                        <label class="layui-form-label w-auto">附加信息:</label>
                        <div class="layui-input-inline">
                            <input name="record" class="layui-input" type="text" placeholder="查询的订单附加信息"/>
                            
                        </div>
                        </div>
                        <div class="layui-inline">
                        <label class="layui-form-label w-auto">创建时间:</label>
                        <div class="layui-input-inline">
                            <input name="order_time" class="layui-input icon-date" placeholder="选择日期范围"
                                   autocomplete="off"/>

                        </div>
                        </div>
                      
                        <div class="layui-inline">
                        <label class="layui-form-label w-auto">所属通道:</label>
                        <div class="layui-input-inline">
                            <input name="mid_type" class="layui-input" type="text" placeholder="输入所属通道"/>
                        </div>
                        </div>
                        <div class="layui-inline">
                        <label class="layui-form-label w-auto">状态:</label>
                        <div class="layui-input-inline">
                            <select name="state">
                                <option value="">选择状态</option>
                                <option value="1">未支付</option>
                                <option value="2">已支付</option>
                                <option value="3">超时</option>
                            </select>
                        </div>
                        </div>
                    <div class="layui-inline" style="padding-right: 110px;">
                        <button class="layui-btn icon-btn" lay-filter="tbBasicTbSearch" lay-submit>
                            <i class="layui-icon">&#xe615;</i>查询
                        </button>
                        
                       
                    </div>
                </div>
                        <!-- 数据表格 -->
            <table id="tbBasicTable" lay-filter="tbBasicTable"></table>
        </div>
    </div>
  
</div>

<script type="text/html" id="eDialogTbState">
     {{# if(d.state==2){ }}
     {{# if(d.api_state==2){ }}
     <span class="layui-badge layui-badge-green">已回调</span>
     {{# }else if(d.api_state==1){ }}
     <span class="layui-badge layui-badge-blue">未请求</span>
     {{# }else if(d.api_state==3){ }}
     <span class="layui-badge layui-badge-grat" lay-event="checkList">回调失败</span>
     {{# } }}
    {{# }else if(d.state==1){ }}
    ---
    {{# }else if(d.state==3){ }}
    ---
    {{# } }}
</script>
<!-- 操作列 -->
<script type="text/html" id="reback_set">
   
     {{# if(d.api_state==2){ }}
     ---
     {{# }else if(d.api_state==1){ }}
     <a class="layui-btn icon-btn layui-btn-xs" lay-event="add_reback">手动补单</a>
     {{# }else if(d.api_state==3){ }}
     <a class="layui-btn icon-btn layui-btn-xs" lay-event="add_reback">重新补单</a>
     {{# } }}
   
</script>
<script id="eDialogCheckDialog" type="text/html">
    <div style="padding: 25px 25px 25px 30px;">
        {{d.api_jieguo}}
    </div>
</script>

<!-- js部分 -->
<script type="text/javascript" src="__STATIC__assets/libs/layui/layui.js"></script>
<script type="text/javascript" src="__STATIC__assets/js/common.js?v=318"></script>
<script>
    layui.use(['layer', 'form','laytpl','admin','table', 'util', 'dropdown','baseTable','laydate'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var table = layui.table;
        var util = layui.util;
        var dropdown = layui.dropdown;
        var laytpl = layui.laytpl;
        var admin = layui.admin;
        var laydate = layui.laydate;
        /* 渲染表格 */
        var insTb = table.render({
            elem: '#tbBasicTable',
            url: "getOrders",
            page: true,
            cellMinWidth: 100,
            cols: [[
                {type: 'checkbox'},
                {field: 'order_id', title: '订单号',minWidth:120,align:'center'},
                {field: 'mid_name', title: '收款账号',minWidth:120,align:'center'},
                {field: 'mid_type', title: '所属通道',minWidth:120,align:'center'},
                {field: 'type', title: '支付方式',minWidth:120,align:'center', templet: function (d) {
                        var strs = {
                            alipay:'支付宝',
                            weixin:'微信',
                            qq:'Q Q'
                        };
                        return strs[d.type];
                    }
                },
                {field: 'record', title: '附加信息',minWidth:120,align:'center'},
                {field: 'money', title: '金额',minWidth:100,sort:true,align:'center'},
                {field: 'sxf', title: '手续费',minWidth:100,sort:true,align:'center',templet: function(d){
                    if(d.sxf!=0){return d.sxf+'元'}else{return '---'}
                }},
                {field: 'ip', title: '交易IP',minWidth:100,align:'center'},
                {field: 'create_date', title: '创建时间',minWidth:120,align:'center',templet: function(d){
                    if(d.create_date!=0){return util.toDateString(d.create_date*1000)}else{return '---'}
                }},
                {field: 'pay_date', title: '支付|回调时间',minWidth:120,align:'center', templet: function (d) {
                         if(d.pay_date!=0){
                             return util.toDateString(d.pay_date*1000)+'<br>'+util.toDateString(d.pay_time*1000);
                         }else{
                             return '---'
                         }  
                    }
                },
                {field: 'state', title: '状态',minWidth:120,align:'center', templet: function (d) {
                        if(d.api_budan >= '1'){
                            var reback = '(补单)';
                        }else{
                            var reback = '';
                        }
                        var strs = {
                            1:'<span class="layui-badge">未支付</span>',
                            2:'<span class="layui-badge layui-badge-green">已支付'+reback+'</span>',
                            3:'<span class="layui-badge layui-badge-gray">订单超时</span>'
                        };
                        return strs[d.state];
                    }
                },
                {toolbar: '#eDialogTbState', minWidth: 100,align:'center',title: '回调'},
                {toolbar: '#reback_set', title: '操作',minWidth:110,align:'center'},
               
             
            ]]
        });

        /* 表格搜索 */
        form.on('submit(tbBasicTbSearch)', function (data) {
            if (data.field.order_time) {
                var searchDate = data.field.order_time.split(' - ');
                data.field.startDate = searchDate[0];
                data.field.endDate = searchDate[1];
            } else {
                data.field.startDate = null;
                data.field.endDate = null;
            }
            
            data.field.order_time = undefined;
            insTb.reload({where: data.field, page: {curr: 1}});
            return false;
        });

        /* 表格工具条点击事件 */
        table.on('tool(tbBasicTable)', function (obj) {
            var data = obj.data; // 获得当前行数据
            var layEvent = obj.event;
            if (obj.event === 'add_reback') { // 补单回调
                add_reback(data);
            } else if (layEvent == 'checkList') {
                openCheckList(data);
            } 
            dropdown.hideAll();
        });
               /* 渲染创建时间选择 */
        laydate.render({
            elem: 'input[name="order_time"]',
            type: 'date',
            range: true,
            trigger: 'click'
        });
        
         /* 渲染支付时间选择 */
        laydate.render({
            elem: 'input[name="pay_time"]',
            type: 'date',
            range: true,
            trigger: 'click'
        });
        
        function add_reback(obj){
            
            layer.confirm('确定要处理此订单吗？<br><span style="color:red">确认处理后将进行补单，届时该订单将变更为已支付和进行回调处理,该通道相应的金额也会计入</span>,已知晓请确认!', {
                shade: .1,
                skin: 'layui-layer-admin'
                }, function (i) {
                layer.close(i);
                    layer.load(2);
                    $.get("reback", {
                        id: obj.id
                    }, function (res) {
                        layer.closeAll('loading');
                        if (res.code == 1) {
                            layer.msg(res.msg, {icon: 1});
                            insTb.reload({page: {curr: 1}});
                           
                        } else {
                            layer.msg(res.msg, {icon: 2});
                            insTb.reload({page: {curr: 1}});
                        }
                    }, 'json');
                
            });
        }
        
         // 回调内容弹窗
        function openCheckList(d) {
            laytpl(eDialogCheckDialog.innerHTML).render(d, function (html) {
                admin.open({
                    type: 1,
                    title: '回调结果',
                    content: html
                });
            });
        }
        
        
    });
    
    
</script>
</body>
</html>